@include('admin.layout.bone_header')

<div class="layui-btn-container">

</div>

<blockquote class="layui-elem-quote">订单总数:{{$countOrder['countAll']}}    订单待返费:{{$countOrder['countDai']}}   订单已返费:{{$countOrder['countFan']}}</blockquote>


<table class="layui-hide" id="think-table" lay-filter="think-table"></table>

<script type="text/html" id="barDemo">

    <a class="layui-btn layui-btn-xs" lay-event="recharge">充值</a>


</script>

<script>

    layui.use('table', function () {
        let table = layui.table;
        UI.getPageTable(table, "{{route('admin.orders.orders')}}", [
            {field: 'u_order_id', title: 'ID', width: 80, sort: true, fixed: 'left'}
            , {field: 'u_price', title: '下单金额'}
            , {field: 'u_over_rate_price', title: '预估收益'}
            , {field: 'u_rate', title: '预估收益比例',templet:function (d){
                    return d['u_rate']*100+'%'
                }}
            , {field: 'u_day_over', title: '预估收益时间',templet:function (d){
                    return Utils.paraseTime(d['u_day_over'])
                }}
            , {field: 'u_status', title: '订单状态',templet:function (d){
                    let arr = ['处理中',"<font color='green'>返费成功</font>","<font color='red'>返费失败</font>"];
                    return arr[d['u_status']]
                }}
            , {field: 'u_day_over', title: '下单时间',templet:function (d){
                    return Utils.paraseTime(d['created_at'])
                }}
            // , {field: 'user_level', title: '用户等级',templet:function (d){
            //         let arr = {0:'普通用户',10:'一星用户',20:'二星用户',30:'三星用户',40:'四星用户',50:'五星用户'};
            //         return arr[d['user_level']];
            //     }}
        ]);

        table.on('tool(think-table)', function (obj) {
            let data = obj.data;
            if(obj.event === 'recharge') {
                layer.prompt({formType:0,title:"充值",value:10000},
                    function(value, index){
                        {{--HttpUtils.post('{{route('admin.users.recharge')}}',{--}}
                        {{--    money:value,--}}
                        {{--    user_id:data['user_id']--}}
                        {{--},function (res){--}}
                        {{--    if(res['code'] != 200){--}}
                        {{--        Utils.errorToast(res['msg'])--}}
                        {{--        return;--}}
                        {{--    }--}}
                        {{--    layer.close(index)--}}
                        {{--    layui.table.reload("think-table");--}}
                        {{--});--}}
                    });
            }
        });
        let $ = layui.$, active = {

        };
        $('.layui-btn-container .layui-btn').on('click', function () {
            let type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

        $('.search .layui-btn').on('click', function () {
            let type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

    })


</script>


@include('admin.layout.bone_footer')
